package com.an.blog.web.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.an.blog.service.IBlogFriendLinkService;
import com.an.blog.web.domain.bo.BlogFriendLinkWebBo;
import com.an.blog.web.domain.vo.BlogFriendLinkWebVo;
import com.an.common.annotation.Log;
import com.an.common.core.controller.BaseController;
import com.an.common.core.domain.R;
import com.an.common.core.validate.AddGroup;
import com.an.common.enums.BusinessType;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 博客好友链接控制器
 *
 * @author: Ann
 * @createDate: 2023/10/23 15:35:18
 * @version: 1.0.0
 */
@SaIgnore
@RestController
@RequestMapping("/blog-web/friendLink")
@RequiredArgsConstructor
public class BlogFriendLinkWebController extends BaseController {

    private final IBlogFriendLinkService blogFriendLinkService;


    /**
     * 查询好友链接web列表
     *
     * @return {@link R }<{@link BlogFriendLinkWebVo }>
     * @author: Ann
     * @createDate: 2023/10/23 15:54:27
     * @version: 1.0.0
     */
    @GetMapping("/list")
    public R<List<BlogFriendLinkWebVo>> queryFriendLinkWebList() {
        return R.ok(blogFriendLinkService.queryFriendLinkWebList());
    }

    /**
     * 申请好友链接
     *
     * @param blogFriendLinkWebBo 博客好友链接网站博
     * @return {@link R }<{@link Void }>
     * @author: Ann
     * @createDate: 2023/10/24 08:52:49
     * @version: 1.0.0
     */
    @PostMapping("/apply")
    @Log(title = "友情链接", businessType = BusinessType.INSERT)
    public R<Void> applyForFriendLink(@RequestBody @Validated(AddGroup.class) BlogFriendLinkWebBo blogFriendLinkWebBo) {
        return toAjax(blogFriendLinkService.applyForFriendLink(blogFriendLinkWebBo));
    }
}
